import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# 数据点
bf = np.array([0, 1, 2, 3, 4, 5])
tf = np.array([5, 4, 3, 2, 1, 0])
p = np.array([5.17, 7.16, 7.77, 10.00, 11.48, 12.42])

# 创建3D图
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')

# 绘制散点
scatter = ax.scatter(bf, tf, p, c='red', marker='o')

# 添加连接线
ax.plot(bf, tf, p, c='blue', linestyle='-')

# 为每个点添加标签
for i in range(len(bf)):
    ax.text(bf[i], tf[i], p[i], f'{p[i]}%', fontsize=8)

# 设置轴标签
ax.set_xlabel('bf')
ax.set_ylabel('tf')
ax.set_zlabel('Probability (%)')

# 设置轴范围
ax.set_xlim(0, 5)
ax.set_ylim(0, 5)
ax.set_zlim(0, 15)

# 调整视角
ax.view_init(elev=20, azim=45)

# 显示网格
ax.grid(True)

plt.title('3D Probability Distribution')
plt.show()